<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*
        await 运算符
        1. 一元运算符，运算单元可以是任意数据类型
        2. 必须在异步函数中执行（async修饰的函数）
        3. 对非promise数据类型，直接返回运算单元
        4. 对promise数据类型，如果执行resolve(),返回resolve的参数，如果执行reject()，直接抛出错误。
        */
      const fn1 = async function () {
        const r = await Promise.resolve();
        console.log(r);
      };

      const fn2 = async () => {
        const r = await Promise.resolve();
        console.log(r);
      };

      const obj = {
        async fn1() {
          const r = await Promise.resolve();
          console.log(r);
        },
        fn2: async function () {
          const r = await Promise.resolve();
          console.log(r);
        },
        fn3: async () => {
          const r = await Promise.resolve();
          console.log(r);
        },
      };

      class Peronson {
        async say() {
          const r = await Promise.resolve();
          console.log(r);
        }
        static async say() {
          const r = await Promise.resolve();
          console.log(r);
        }
      }
    </script>
  </body>
</html>
